<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 原先具备iterator接口的可以使用 for...of 循环  
        //  数组（arry，Arguments，set，Map，String，nodelist
        let arr =['胡歌','彭于晏','侯卿','蚩梦']
        console.log(arr);
        let iterators=arr[Symbol.iterator]()
        console.log(iterators);
        console.log(iterators.next());
        for(let i of arr){
            console.log(i);
        }

     let   obj ={
        name:'胡歌',
        age:40,
        lists:['胡歌','彭于晏','侯卿','蚩梦'],


        
        // 自定义迭代就是在里面埋下这个[Symbol.iterator]() 但是只对里面有线性数据的
        [Symbol.iterator](){
            let index=0;
            return{
                next:()=>{
                     return{value:this.lists[index++],
                        done:index===this.lists.length ?true:false}
                }
            }
        }
     }
      
     console.log(obj);
     for (let v of obj) {
        console.log(v);
     }


    </script>
</body>
</html>